﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Work.aspx.cs" Inherits="home_Work" %>
<%@ Register TagPrefix="PM" TagName="LeftMenu" Src="~/control/LeftMenu.ascx" %>
<%@ Register TagPrefix="PM" TagName="Header" Src="~/control/Header.ascx" %>
<%@ Register TagPrefix="PM" TagName="Footer" Src="~/control/Footer.ascx" %>
<%@ Register TagPrefix="PM" TagName="Pager" Src="~/control/Pager.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Works management</title>
    <link rel="Stylesheet" type="text/css" href="../css/style.css" media="all" />
    <link rel="Stylesheet" type="text/css" href="../css/window.css" media="all" />
    <link rel="Stylesheet" type="text/css" href="../css/button.css" media="all" />
    
    <script type="text/javascript" language="javascript" src="../js/jquery-1.4.1.js"></script>
    <script type="text/javascript" language="javascript" src="../js/commonfunctions.js"></script>
    <script type="text/javascript" language="javascript" src="../js/work.js"></script>
    <script type="text/javascript" language="javascript" src="../js/dragwindow.js"></script>
    <script type="text/javascript" language="javascript">
        setDrag("#window_add");
        setDrag("#window_review");
        setDrag("#window_note");
        setDrag("#div_comment");
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <PM:Header ID="header" runat="server" />
        <div class="clear"></div>
        <table>
            <tr>
                <td style="vertical-align:top;">
                    <PM:LeftMenu ID="left_menu" runat="server" />
                </td>
                <td style="vertical-align:top;">
                    <div id="main">
                        <asp:Panel runat="server" ID="menu">
                            <a href="#" id="add">
                                <img alt="" src="../images/Add.png" />
                                <span>Thêm mới</span>
                            </a>
                            <!--<asp:LinkButton runat="server" ID="edit">
                                <img alt="" src="../images/Edit.png" />
                                <span>Sửa</span>
                            </asp:LinkButton>
                            <asp:LinkButton runat="server" ID="delete">
                                <img alt="" src="../images/Delete.png" />
                                <span>Xóa</span>
                            </asp:LinkButton>
                            -->
                        </asp:Panel>
                        <div style="float:right;">
                            <span runat="server" id="label1">Sắp xếp theo</span>
                            <asp:DropDownList runat="server" ID="orderby" AutoPostBack="true" onselectedindexchanged="orderby_SelectedIndexChanged" 
                                
                                >
                                <asp:ListItem Selected="True" Text="Người thực hiện" Value="username"></asp:ListItem>
                                <asp:ListItem Text="Người giao" Value="leadername"></asp:ListItem>
                                <asp:ListItem Text="Chuyên mục" Value="catalogname"></asp:ListItem>
                                <asp:ListItem Text="Mức ưu tiên" Value="priority"></asp:ListItem>
                                <asp:ListItem Text="Trạng thái" Value="status"></asp:ListItem>
                                <asp:ListItem Text="Thời điểm bắt đầu" Value="start"></asp:ListItem>
                                <asp:ListItem Text="Thời điểm kết thúc" Value="[end]"></asp:ListItem>
                                <asp:ListItem Text="Nội dung" Value="[content]"></asp:ListItem>
                            </asp:DropDownList>
                            <span runat="server" id="label2">Theo thứ tự</span>
                            <asp:DropDownList runat="server" ID="order" AutoPostBack="true" onselectedindexchanged="order_SelectedIndexChanged" 
                                
                                >
                                <asp:ListItem Selected="True" Text="Giảm dần" Value="DESC"></asp:ListItem>
                                <asp:ListItem Text="Tăng dần" Value="ASC"></asp:ListItem>
                            </asp:DropDownList>
                        </div>
                        <div class="clear"></div>
                        <asp:GridView runat="server" ID="works" AutoGenerateColumns="false"
                           DataKeyNames="id" Width="100%" CellPadding="5" onrowcommand="works_RowCommand" 
                           
                          >
                         <Columns>
                            <asp:BoundField DataField="id" Visible="false" />
                            <asp:BoundField HeaderText="STT" DataField="order" />
                            <asp:BoundField HeaderText="Nội dung" DataField="content" ItemStyle-CssClass="name" />
                            <asp:TemplateField HeaderText="Miêu tả">
                                <ItemTemplate>
                                    <div>
                                        <%#Eval("description")%>
                                    </div>
                                    <div class="clear"></div>
                                    <a class="note" href="#" id="aNote<%#Eval("id")%>">
                                        <%#comm.DisplayNumberNote(Eval("numbernote").ToString())%>
                                    </a>
                                    <div class="clearheight2"></div>
                                    <div id="divNote<%#Eval("id") %>">
                                    </div>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="Chuyên mục" DataField="catalogname"/>
                            <asp:BoundField HeaderText="Người thực hiện" DataField="username" />
                            <asp:BoundField HeaderText="Người giao" DataField="leadername" />
                            <asp:TemplateField HeaderText="Ưu tiên/ Trạng thái">
                                <ItemStyle CssClass="center middle fill"></ItemStyle>
                                <ItemTemplate>
                                    <div id="divStatus<%#Eval("id")%>" class="<%#DisplayEnum.DisplayStatus(Int32.Parse(Eval("status").ToString())) %>">
                                    <%#DisplayEnum.DisplayPriority(Int32.Parse(Eval("priority").ToString())) %>
                                    </div>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Thời gian">
                                <ItemTemplate>
                                    Start:<%#Eval("start") %><br />
                                    End:<span class="<%#DisplayEnum.DisplayStatus(Int32.Parse(Eval("status").ToString())) %>"><%#Eval("end") %></span>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Chức năng" ItemStyle-Width="60">
                                 <ItemTemplate>
                                    <% if (isLeader)
                                       { %>
                                       <a href="#" id="editWork" onclick="return editWork('<%#Eval("id")%>');" title="Chỉnh sửa">
                                          <img alt="" src="../images/Edit.png"/>
                                        </a>
                                        <asp:LinkButton PostBackUrl="#" runat="server" CommandName="removeWork" CommandArgument='<%#Eval("id")%>' 
                                            Visible='<%#isLeader %>' Enabled='<%#isLeader %>' 
                                            ID="removeWork" OnClientClick="return confirm('Xóa công việc này ?');" ToolTip="Xóa" >
                                            <img alt="" src="../images/Delete.png" />
                                        </asp:LinkButton>
                                    <% } %>
                                    <%if (rightUser)
                                      { %>
                                        <a href="#" id="reviewWork" onclick="return displayReview('<%#Eval("id")%>');" title="Đánh giá" >
                                            <img alt="" src="../images/Verify.png"  />
                                        </a>
                                        <a href="#" id="noteWork" onclick="return displayNote('<%#Eval("id")%>');" title="Chú thích" >
                                            <img alt="" src="../images/Comment.png" />
                                        </a>
                                    <%} %>
                                </ItemTemplate>
                            </asp:TemplateField>
                         </Columns>
                        </asp:GridView>
                        <asp:Label runat="server" ID="display">Chưa có công việc nào</asp:Label>
                        <div>
                            <div class="clearheight2"></div>
                            <span class="blockstatus unrelized_status"></span>
                            <span class="blockstatustext">Chưa thực hiện</span>
                            <div class="clearheight2"></div>
                            <span class="blockstatus doing_status"></span>
                            <span class="blockstatustext">Đang thực hiện</span>
                            <div class="clearheight2"></div>
                            <span class="blockstatus done_status"></span>
                            <span class="blockstatustext">Hoàn thành</span>
                            <div class="clearheight2"></div>
                        </div>
                        <PM:Pager runat="server" ID="pager" Visible="false" />
                    </div>
                </td>
            </tr>
        </table>
        <div class="clear"></div>
        <PM:Footer runat="server" ID="footer" />
        
        <!-- pop up window -->
        <div class="transparent_window" >
        </div>
        
        <!-- pop up window for adding/editing work -->
        <div class="content_window" id="window_add">
            <div class="header">
                <span id="window_title">Thêm công việc</span>
                <a href="#" class="close">&nbsp;</a>
            </div>
            <div class="main">
                <table cellpadding="2px" cellspacing="0" width="85%">
                    <tr>
                        <td class="title">Nội dung</td>
                        <td>
                            <input type="text" id="content_work" style="width:260px;" />
                        </td>
                    </tr>
                    <tr>
                        <td class="title">Miêu tả</td>
                        <td>
                            <textarea id="des_work" cols="30" rows="5" style="margin:0;">
                            </textarea>
                        </td>
                    </tr>
                    <tr>
                        <td class="title">
                            Chuyên mục
                        </td>
                        <td> 
                            <asp:DropDownList runat="server" ID="catalog_work">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="title">
                            Mức độ ưu tiên
                        </td>
                        <td> 
                            <asp:DropDownList runat="server" ID="priority_work">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="title">
                            Người thực hiện
                        </td>
                        <td> 
                            <asp:DropDownList runat="server" ID="username_work">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="title">
                            Bắt đầu
                        </td>
                        <td> 
                            <input type="text" id="start_work" />(dd/mm/yyyy)
                        </td>
                    </tr>
                    <tr>
                        <td class="title">
                            Kết thúc
                        </td>
                        <td> 
                            <input type="text" id="end_work" />(dd/mm/yyyy)
                        </td>
                    </tr>
                </table>
            </div>
            <div class="footer">
                <asp:LinkButton ID="btOk" runat="server" Text="OK" CssClass="ok" OnClientClick="return addWork();"
                 OnClick="btOk_Click" 
                 >
                </asp:LinkButton>
                <a href="#" class="cancel">Cancel</a>
            </div>
        </div>
        
        <!-- pop up window for review work -->
        <div class="content_window" id="window_review">
            <div class="header">
                <span id="title_review">Đánh giá công việc</span>
                <a href="#" class="close">&nbsp;</a>
            </div>
            <div class="main">
                <table cellpadding="2px" cellspacing="0" width="85%">
                    <tr>
                        <td class="title">Công việc</td>
                        <td>
                            <input type="text" id="workcontent_review" style="width:300px;" readonly="readonly" />
                        </td>
                    </tr>
                    <tr>
                        <td class="title">Nội dung</td>
                        <td>
                            <asp:TextBox runat="server" Width="300px" Height="180px" ID="content_review" TextMode="MultiLine">
                            </asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="title">
                            Trạng thái
                        </td>
                        <td> 
                            <asp:DropDownList runat="server" ID="status_work">
                            </asp:DropDownList>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="footer">
                <asp:LinkButton ID="btReview" runat="server" Text="OK" CssClass="ok" OnClientClick="return reviewWork();"
                 OnClick="btOk_Click" 
                 >
                </asp:LinkButton>
                <a href="#" class="cancel">Cancel</a>
            </div>
        </div>
        
        <!-- pop up window for note work -->
        <div class="content_window" id="window_note">
            <div class="header">
                <span id="title_note">Chú thích công việc</span>
                <a href="#" class="close">&nbsp;</a>
            </div>
            <div class="main">
                <table cellpadding="2px" cellspacing="0" width="85%">
                    <tr>
                        <td class="title">Công việc</td>
                        <td>
                            <input type="text" id="workcontent_note" style="width:300px;" readonly="readonly" runat="server" />
                            <input type="hidden" id="workId" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td class="title" style="width:65px;">Nội dung</td>
                        <td>
                            <asp:TextBox ID="content_note" runat="server" TextMode="MultiLine" Width="300px" Height="150px">
                            </asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="title">&nbsp;</td>
                        <td>
                            <span style="font-style:italic;">Chỉ hỗ trợ file upload <= 2MB</span>
                            <input type="file" id="fileupload1" name="fileupload1" runat="server" />
                            <input type="file" id="fileupload2" name="fileupload2" runat="server" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="footer">
                <asp:LinkButton ID="btNote" runat="server" Text="OK" CssClass="ok" OnClientClick="return noteWork();"
                 OnClick="btNote_Click" 
                 >
                </asp:LinkButton>
                <a href="#" class="cancel">Cancel</a>
            </div>
        </div>
        
        <!-- pop up window for displaying comment -->
        <div class="comment_window" id="div_comment">
            <div class="header">
                <span id="title_comment">Chú thích công việc</span>
                <a href="#" class="close">&nbsp;</a>
            </div>
            <div class="main">
            </div>
            <div class="footer">
                <a href="#" class="cancel" id="makenotework">Chú thích</a>
                <a href="#" class="cancel">Thoát</a>
            </div>
        </div>
    </form>
</body>
</html>
